package com.acme.bankapp.domain.bank;

public class Account {
	private int balance;
	
	public Account(int balance) throws Exception {
		if (balance < 0)
			throw new Exception("Balance must be positive or zero value");
		this.balance = balance;
	}
	
	public void deposit(int x) throws Exception {
		if (x < 0)
			throw new Exception("Number of deposit must be positive value");
		
		this.balance += x;
	}
	
	public void withDraw(int x) throws Exception {
		if (x <= 0)
			throw new Exception("Number of deposit must be positive value");
		else if (balance < x) 
			throw new Exception("Balance is less than required value");
		
		balance -= x;
	}
	
	public int getBalance() {
		return balance;
	}	
}
